package com.ruoyi.web.controller.food;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.food.domain.StatisticsDTO;
import com.ruoyi.food.domain.vo.StatisticsVO;
import com.ruoyi.food.service.IStatisticsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 统计
 */
@RestController
@RequestMapping("/dashboard")
public class StatisticsController {

    @Autowired
    private IStatisticsService statisticsService;

    // 获取折线图数据
    @ApiOperation("获取折线图数据")
    @GetMapping("/getLineData")
    public AjaxResult getLineData(StatisticsVO params){

        Map<String, Object> map = new HashMap<>();

        // 按照日/月统计
        List<StatisticsDTO> byDateStat = statisticsService.getByDateStat(params);

        map.put("byDateStat", byDateStat);
        return AjaxResult.success(map);
    }

    /**
     * 获取入库价格统计
     */
    @ApiOperation("获取入库价格统计")
    @GetMapping("/getEntryPriceStat")
    public AjaxResult getEntryPriceStat(StatisticsVO params){
        List<StatisticsDTO> entryPriceStat = statisticsService.getEntryPriceStat(params);
        return AjaxResult.success(entryPriceStat);
    }

    /**
     * 获取出库价格统计
     */
    @ApiOperation("获取出库价格统计")
    @GetMapping("/getOutPriceStat")
    public AjaxResult getOutPriceStat(StatisticsVO params){
        List<StatisticsDTO> entryPriceStat = statisticsService.getOutPriceStat(params);
        return AjaxResult.success(entryPriceStat);
    }

    @ApiOperation("获取库存统计")
    @GetMapping("/getStockList")
    public AjaxResult getStockList(StatisticsVO params){
        List<StatisticsDTO> stockList = statisticsService.getStockList(params);
        return AjaxResult.success(stockList);
    }

    @ApiOperation("获取库存统计")
    @GetMapping("/getTotalPriceStat")
    public AjaxResult getTotalPriceStat(StatisticsVO params){
        return AjaxResult.success();
    }
}
